package com.ztgf.shopping.api.client.epg;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgMainNavigationBO;
import com.ztgf.shopping.models.dto.epg.EpgMainNavigationDTO;
import com.ztgf.shopping.models.service.epg.IEpgMainNavigationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 主导航控制器
 *
 * @author YUE
 * @create 2020-05-18 11:36
 */

@RestController
@RequestMapping("/api/epgMainNavigation")
@Slf4j
@Api(value = "EpgMainNavigationApiController",tags = "主导航Api接口")
public class EpgMainNavigationApiController {

    @DubboReference
    private IEpgMainNavigationService epgMainNavigationService;

    /**
     * 主导航列表 根据功能id
     * @param moduleId 功能id
     * @return
     */
    @ApiOperation(value = "主导航列表 根据功能id",notes = "主导航列表 根据功能id")
    @PostMapping("/getListByModuleId")
    public Result<List<EpgMainNavigationDTO>> getListByModuleId(Long moduleId){
        EpgMainNavigationBO epgMainNavigationBO = new EpgMainNavigationBO();
        epgMainNavigationBO.setModuleId(moduleId);
        List<EpgMainNavigationDTO> epgMainNavigationDTOList = epgMainNavigationService.getBySelectMainNavigationInfoNoPage(epgMainNavigationBO);
        return new Result<>(epgMainNavigationDTOList);
    }



    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<EpgMainNavigationDTO> get(Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }
        EpgMainNavigationDTO epgMainNavigationDTO = epgMainNavigationService.selectById(id);
        return new Result<>(epgMainNavigationDTO);
    }

    @ApiOperation(value = "主导航列表",notes = "主导航列表")
    @PostMapping("/querySelectList")
    public Result<List<EpgMainNavigationDTO>> querySelectList( EpgMainNavigationBO epgMainNavigationBO){
        if(null == epgMainNavigationBO)
            return new Result<>(CodeEnum.FAIL_100002 );
        List<EpgMainNavigationDTO> epgMainNavigationDTOList = epgMainNavigationService.getBySelectMainNavigationInfoNoPage(epgMainNavigationBO);
        return new Result<>(epgMainNavigationDTOList);
    }
}
